import os

from loguru import logger as lg

from config import LOG_FILE, LOG_LEVEL


def set_logger():
    LOG_dir = os.path.dirname(LOG_FILE)
    if not os.path.exists(LOG_dir):
        os.makedirs(LOG_dir)
    lg.add(
        LOG_FILE,
        level=LOG_LEVEL,
        # format='【{time:YYYY-MM-DD HH:mm:ss} {level} {file} {line}】{message}',
    )
    return lg


logger = set_logger()
